<include file="header" />
<body>
<div class="wraper">
    <div class="head clearfix">
        <a href="javascript:history.back();" class="iconfont icon-zuo pull-left"></a>
        <span class="head-name pull-left">{BEESCRM:$app_name}</span>
        <a href="{BEESCRM::U('/Charger/Chargingprox/index',array('accountId'=>$accountId))}" class="iconfont icon-shouye pull-left text-right"></a>
    </div>

    <if condition="!$data">
        <!--<div class="text-12 text-center text-green padding">暂无记录~</div>-->
        <!--没有记录-->
        <div class="norecord">
            <img src="/assets/charger/images/nonelist.png"/>
            <p>暂无充电记录</p>
        </div>
    <else/>
        <div class="title padding tb-mode">
            <p class="tb-cell">截止目前累计记录</p>
        </div>
        <div class="lists text-center clearfix">
            <div class="second-list">
                <p class="text-green text-20">{BEESCRM:$chargingData.chargingNum}</p>
                <p class="text-12 text-grey">充电次数/次</p>
            </div>
            <div class="second-list">
                <p class="text-green text-20">{BEESCRM:$chargingData.chargingTime}</p>
                <p class="text-12 text-grey">充电时长/分钟</p>
            </div>
        </div>
        <div class="year-time tb-mode">
            <p class="tb-cell">{BEESCRM:$Think.const.NOW_TIME|date='Y',###}</p>
        </div>
        <div class="lists append">
            <volist name="data" id="vo" key="k">
                <div class="list-line">
                    <p>{BEESCRM:$vo.end_time|date='m-d H:i:s',###}</p>
                </div>
                <div class="list-line text-12">
                    <p class="clearfix">
                        消耗：<span class="text-red">{BEESCRM:$vo.consume_money}元</span>
                    </p>
                    <p><span class="text-grey">上期剩余：{BEESCRM:$vo['surplus_money']+$vo['consume_money']}</span><span class="pull-right">当前结余：{BEESCRM:$vo.surplus_money}</span></p>
                </div>
            </volist>
        </div>
    </if>
    <div class="text-12 text-center text-green padding" style="display: none" id="load_more">加载中...</div>
</div>

<input type="hidden" name="count" id="count" value="{BEESCRM:$count}" />
<input type="hidden" name="block" id="block" value="{BEESCRM:$block}" />

<input type="hidden" name="hasChargingRecord" id="hasChargingRecord" value="{BEESCRM:$hasChargingRecord}" />
<include file="commonJS"/>
<script>
    seajs.use("$",function() {
        $(window).scroll(function(){
            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(document).height();
            var windowHeight = $(window).height();
            if(scrollTop + windowHeight == scrollHeight){
                var data = {};
                data.count = parseInt($("#count").val()) + 1;
                data.block = $("#block").val();

                if(data.block != 0) {
                    $("#count").val(parseInt(data.count) + 1);
                    $("#block").val(parseInt(data.block) - 1);
                    $.ajax({
                        type:'post',
                        dataType:'json',
                        data:data,
                        url:"{BEESCRM::U('/Charger/Rechargingprox/chargingRecord',array('accountId'=>$accountId))}",
                        beforeSend:function() {
                            $('#load_more').show();
                        },
                        success:function(data){
                            if(data.status == 'S') {
                                $("#count").val(data.data.count);
                                $("#block").val(data.data.block);
                                $(".append").append(data.data.content);
                            }
                        },
                        error:function(){
                            $.alert('error', data.message);
                            return false;
                        }
                    });
                } else {
                    var hasChargingRecord = $("#hasChargingRecord").val();
                    if(hasChargingRecord == 1) {
                        $('#load_more').show();
                        $('#load_more').text('已是最后一条...');
                    }
                }
            }
        });
    });
</script>

</body>
</html>